package com.db.demo.test.redis;


import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;

@Component
public class TopicMessageListener implements MessageListener {
    @Override
    public void onMessage(Message message, byte[] bytes) {
        byte[] body = message.getBody();// 请使用valueSerializer
        byte[] channel = message.getChannel();
        //设置监听频道
        String topic = new String(channel);
        //key
        String itemValue = new String(body);
        System.out.println("频道topic:"+topic);
        System.out.println("过期的键值对的K:"+itemValue);
   }

}